package com.jinmdz.fmis.mapper.mapper;

import com.jinmdz.fmis.mapper.entity.HistoryChargeEntity;
import com.jinmdz.fmis.mapper.mapper.provider.HistoryChargeProvider;
import org.apache.ibatis.annotations.*;

import java.util.ArrayList;

/**
 * 历史费用记录表Mapper
 *
 * @author generator
 * @date 2020-05-14 10:51
 */
public interface HistoryChargeMapper {

    /**
     * 增加HistoryCharge
     *
     * @param entity 数据实体
     * @return
     * @author generator
     * @date 2020-05-14 10:51
     */
    @InsertProvider(type = HistoryChargeProvider.class, method = "insertHistoryCharge")
    @Options(useGeneratedKeys = true, keyProperty = "entity.id", keyColumn = "id")
    void insertHistoryCharge(@Param("entity") HistoryChargeEntity entity);

    /**
     * 删除HistoryCharge
     *
     * @param id             主键
     * @param modifiedUserId 修改用户外键
     * @param version        版本号
     * @return
     * @author generator
     * @date 2020-05-14 10:51
     */
    @Update(" update history_charge set deleted = 1,modified_user_id = #{modifiedUserId},version = unix_timestamp(now()) where id = #{id} and version = #{version} and unmodified = 0 and deleted = 0 ")
    void deletedForHistoryCharge(@Param("id") Integer id, @Param("modifiedUserId") Integer modifiedUserId, @Param("version") Long version);

    /**
     * 修改HistoryCharge
     *
     * @param entity 数据实体
     * @return
     * @author generator
     * @date 2020-05-14 10:51
     */
    @UpdateProvider(type = HistoryChargeProvider.class, method = "updateHistoryCharge")
    void updateHistoryCharge(@Param("entity") HistoryChargeEntity entity);

    /**
     * 查询HistoryCharge实体
     *
     * @param id 主键
     * @return HistoryChargeEntity
     * @author generator
     * @date 2020-05-14 10:51
     */
    @Select(" select id,deleted,business_code,history_no,remark,funeral_parlour_code,create_user_id,gmt_create,unmodified,modified_user_id,gmt_modified,version from history_charge where id = #{id} and deleted = 0 limit 1 ")
    HistoryChargeEntity getHistoryChargeById(@Param("id") Integer id);

    /**
     * 查询HistoryCharge列表
     *
     * @param entity 数据实体
     * @return HistoryChargeEntity
     * @author generator
     * @date 2020-05-14 10:51
     */
    @SelectProvider(type = HistoryChargeProvider.class, method = "listHistoryCharge")
    ArrayList<HistoryChargeEntity> listHistoryCharge(@Param("entity") HistoryChargeEntity entity);
}